home *** CD-ROM | disk | FTP | other *** search
- Path: newsroom.hitc.com!usenet
- From: psand@eos.hitc.com (G. Patrick Sand)
- Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++
- Subject: Re: templatized pointers to member functions (in CW8)
- Date: 1 Feb 1996 18:55:11 GMT
- Organization: Hughes Aircraft (EOSDIS)
- Message-ID: <4er2af$nna@newsroom.hitc.com>
- References: <rshapiro-0102960833080001@ipa.bbn.com>
- NNTP-Posting-Host: 155.157.118.56
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.3
-
- In article <rshapiro-0102960833080001@ipa.bbn.com>, rshapiro@bbn.com
- says...
- >
- >I need to reference a pointer to a member function within a template,
- >where the class of the function is determined by the template parameter.
- >
- >class ATest {
- [snip!]
- >};
- >
- >template <class OBJECT>
- >class Test {
- > // (a) This is what I want but it won't compile in CodeWarrior 8:
- > //typedef void (OBJECT::*ObjectMemberFunction)(void);
- >
- > // (b) This works but isn't what I want:
- > typedef void (ATest::*ObjectMemberFunction)(void);
- >
- [snip!]
- >};
-
- I think the answer is NO. A template is a cookie cutter for whatever you
- specify, but it doesn't assume any knowledge about what you specify
- beyond whether it is a class template or a function template. In this
- case, knowing that a particular function is in the class (your desired
- typedef with the OBJECT::*ObjectMemberFunction... specification) is what
- is causing the problem.
-
- When you specify a class the compiler knows about, namely ATest (i.e.,
- ATest::*ObjectMemberFunction...) it is happy to oblige...
-
- I dug this out of the C++ FAQ book, although it wasn't explicitly
- discussed.
-
- So I might be wrong...
-
- --
- G. Patrick Sand
- psand@eos.hitc.com
- PatSand@aol.com
- (301) 925-0791
- "Travel Light But Right..."
- Microsoft Network is prohibited from redistributing
- this work in any form, in whole or in part. License
- to distribute this individual post is available to Microsoft
- for $999. Posting without permission constitutes an
- agreement to these terms...gps
-
-